<template>
  <div class="today-recommend">
    <div class="head log url">
      <h2>{{title}}</h2>
      <router-link
        :to="{ 
          name: 'MoreList',
          params: {
            title:title
          }
        }"
        tag="div"
      >更多</router-link>
    </div>
    <div class="container">
      <div class="gallery">
        <div class="scroller">
          <router-link :to="{name:'MorePlayList',params:{id: item.id,img: item.coverImgUrl,name: item.name,tags: item.tags}}" class="card url" v-for="(item,index) in commendList" :key="index">
            <div class="album">
              <img :src="item.coverImgUrl" :alt="item.title" />
              <div class="name">{{ item.name }}</div>
            </div>
          </router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "todayRecommend",
  data() {
    return {
      title: "歌单推荐",
      commendList: []
    };
  },
  mounted() {
    const url = this.HOST + "/top/playlist?limit=6&order=hot&offset=0";
    this.$axios
      .get(url)
      .then(res => {
        this.commendList = res.data.playlists;
      })
      .catch(err => console.log('今日推荐报错', err.response.data.message));
  }
};
</script>

<style scoped>
.today-recommend {
  background-color: #fff;
  padding: 10px 17px;
}

.head {
  display: flex;
  margin: 14px 0 18px 0;
}

.head h2 {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  margin: 0;
  padding: 0;
  font-size: 20px;
}

.head div {
  width: 64px;
  font-size: 12px;
  text-align: right;
}

.today-recommend .gallery {
  overflow: hidden;
  margin: 0 -5px;
}

.today-recommend .gallery .card {
  width: 33.3%;
  float: left;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  padding: 0 5px 10px;
}

.today-recommend .gallery .card .album {
  position: relative;
}

.today-recommend .gallery .card img {
  width: 100%;
  height: auto;
  border: 1px solid #eee;
}

.today-recommend .gallery .card .name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
  line-height: 14px;
  max-height: 28px;
  margin-bottom: 2px;
}
</style>